<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>后盾人</title>
  </head>
  <body>
    <input type="text" name="username" />
  </body>
  <script>
    document.querySelector(`[name="username"]`).addEventListener("keyup", e => {
      const value = e.target.value;
      let reg = /^[a-z][\w-]{2,7}$/i;
      console.log(reg.test(value));
    });
  </script>
</html>
